package com.zackeus.sipservice.entity;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * SIP 注册状态
 * @name: SipRegStatus
 * @author: zz
 * @date: 2022/9/26
 */
public class SipRegStatus implements Parcelable {

    private final String accountId;
    /* 是否具有注册设置 */
    private final boolean configured;
    /* 是否正在注册 */
    private final boolean active;
    /* 最后一次注册状态码 状态码为零，则该帐户当前未注册。任何其他值表示注册的SIP状态代码 */
    private final int status;
    /* 描述注册状态字符 */
    private final String statusText;
    /* 注册会话的最新到期时间间隔 */
    private final long expiresSec;
    /* 存在此帐户的在线状态 */
    private final boolean onlineStatus;
    /* 在线状态文本 */
    private final String onlineStatusText;

    public SipRegStatus(String accountId, boolean configured, boolean active, int status,
                        String statusText, long expiresSec, boolean onlineStatus, String onlineStatusText) {
        this.accountId = accountId;
        this.configured = configured;
        this.active = active;
        this.status = status;
        this.statusText = statusText;
        this.expiresSec = expiresSec;
        this.onlineStatus = onlineStatus;
        this.onlineStatusText = onlineStatusText;
    }

    protected SipRegStatus(Parcel in) {
        this.accountId = in.readString();
        this.configured = in.readByte() == 1;
        this.active = in.readByte() == 1;
        this.status = in.readInt();
        this.statusText = in.readString();
        this.expiresSec = in.readLong();
        this.onlineStatus = in.readByte() == 1;
        this.onlineStatusText = in.readString();
    }

    public String getAccountId() {
        return accountId;
    }

    public boolean isConfigured() {
        return configured;
    }

    public boolean isActive() {
        return active;
    }

    public int getStatus() {
        return status;
    }

    public String getStatusText() {
        return statusText;
    }

    public long getExpiresSec() {
        return expiresSec;
    }

    public boolean isOnlineStatus() {
        return onlineStatus;
    }

    public String getOnlineStatusText() {
        return onlineStatusText;
    }

    public static final Creator<SipRegStatus> CREATOR = new Creator<SipRegStatus>() {
        @Override
        public SipRegStatus createFromParcel(Parcel in) {
            return new SipRegStatus(in);
        }

        @Override
        public SipRegStatus[] newArray(int size) {
            return new SipRegStatus[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.accountId);
        parcel.writeByte((byte) (this.configured ? 1 : 0));
        parcel.writeByte((byte) (this.active ? 1 : 0));
        parcel.writeInt(this.status);
        parcel.writeString(this.statusText);
        parcel.writeLong(this.expiresSec);
        parcel.writeByte((byte) (this.onlineStatus ? 1 : 0));
        parcel.writeString(this.onlineStatusText);
    }
}
